package mythesis.tiles.character;
import mythesis.gui.main.components.api.TilePopupButton;
import javafx.scene.*;
import javafx.scene.shape.*;
import javafx.scene.paint.*;
import javafx.scene.text.*;
import javafx.scene.image.*;
import javafx.scene.input.*;

public class ListenToSuggestion extends CustomNode
{  
    var dir = "{{__DIR__}.substring(0, {__DIR__}.length()-16)}resource/";
    var defFill = "#2E5B89";
    var altFill = "#366CA3";
    var curFill = defFill;
    
    public var argClick = -1;				// which argument is clicked

 	// ----- XML -----   
    public var line    					   = 0;			// where tile is sticked to
    public var args:String[] 			   = [""];	// text displayed for each arg box
    public var dataType:Number[]           = [0];
    public var dataValue:Number[]          = [0];
    // --- END XML ---

    public var allowedDataTypes1:Boolean[] = [true, false, false];
    public var allowedDataValue1:Boolean[] = [false, true, false];
    public var bonusVariables:String[] = ["suggester", "disproved", "disprover"];
    public var bonusVariableTypes:String[] = ["Word", "Truth", "Word"];
    
    public var specialVariables1:String[] = ["You're not supposed", "to see this. :()"];
    
    public function setDataValue(arg:Integer, dval:Number)
    {
        dataValue[arg] = dval;
    }
    
    public function getDataValue(arg:Number):Number
    {
        if (arg==0)        		{ return dataValue[arg as Integer];	}
        else                    { return 0;			}
    }
    
    public function setDataType(arg:Integer, type:Number)
    {
        dataType[arg] = type;
    }
    
    public function getDataType(arg:Number):Number
    {
        if (arg==0)        		{ return dataType[arg as Integer];	}
        else                    { return 0;			}
    }
    
    public function getAllowedDataTypes():Boolean[]
    {
        if (argClick==0)		{	return allowedDataTypes1;	}
        else					{	return [false, false, false];	}
    }
    
    public function getAllowedDataValues():Boolean[]
    {
        if (argClick==0)		{	return allowedDataValue1;		}
        else					{	return [false, false, false];	}
    }
    
    public function getSpecialVariables():String[]
    {
        if (argClick==0)		{	return specialVariables1;	}
        else					{	return [""];				}
    }


    var icon = Group
    {
        content:
        [
        	ImageView
        	{
        	    x      : 10
        	    y      : 2
        	    image  : Image
        	    		 {
							url    : "{dir}icoListen.png";
					        width  : 15
					        height : 15
        	    		 }
        	    cache  : true
        	}
        ]
    }
    
    var tile = Group
    {
        content:
        [
        	Rectangle
        	{
        	    width     : 400
        	    height    : 19
        	    arcWidth  : 10
        	    arcHeight : 10
        	    fill      : bind Color.web(curFill)
        	    onMouseEntered: function(e:MouseEvent):Void
        	    				{
        	    				    curFill = altFill;
        	    				}
        	    onMouseExited:  function(e:MouseEvent):Void
        	    				{
        	    				    curFill = defFill;
        	    				}
        	}
        	Rectangle
        	{
        	    width     : 400
        	    height    : 100
        	    opacity   : 0.0
        	    translateX: -50
        	    translateY: -50
        	}
        ]
    }
    
    var tileShadow = Group
    {
        translateX: -1
        translateY: 1
        content:
        [
        	Rectangle
        	{
        	    width     : 400
        	    height    : 19
        	    arcWidth  : 10
        	    arcHeight : 10
        	    fill      : Color.web("#172F46")
        	}
        ]
    }
    
    var text = Group
    {
        translateY: 14
        content:
        [
        	Text
        	{
        	    x       : 35
        	    content : "Listen to suggestion"
        	    fill    : Color.WHITE
        	}
        ]
    }
    
	var textShadow = Group
    {
        translateX: -1
        translateY: 15
        content:
        [
        	Text
        	{
        	    x       : 35
        	    content : "Listen to suggestion"
        	    fill    : Color.BLACK
        	}
        ]
    }
    
    var field = Group
    {
        content:
        [

        ]
    }
    
    
    public var group = Group
    {
        translateY: bind 20*line;
        content:
        [
        	tileShadow,
        	tile,
        	icon,
        	textShadow,
        	text,
        	field
        ]
    }
    
    override public function create():Node
    {
        return group;
    }
}